package cn.tedu.supermarket.mapper;

import cn.tedu.supermarket.entity.Address;
import cn.tedu.supermarket.entity.AddressDTO;
import cn.tedu.supermarket.entity.AddressVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AddressMapper {
    @Insert("insert into address values(null,#{userId},#{name},#{phone},#{address})")
    Integer addAddress(AddressVO addressVO);

    @Select("select id from address where userId=#{userId} and name=#{name} and phone=#{phone} and address=#{address}")
    Integer selectAddress(AddressVO addressVO);

    @Select("select * from address where userId=#{userId}")
    List<Address> selAddressByUserId(Integer userId);

    @Delete("delete from address where id=#{id}")
    Integer deleteById(int id);

    @Select("select id,name,phone,address from address where id=#{id}")
    AddressDTO selectById(int id);
}
